package org.jctc.els.modules.biz.service.projects.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.jctc.els.modules.biz.entity.projects.ElsProjectFiles;
import org.jctc.els.modules.biz.entity.projects.ElsProjectFilesCategory;
import org.jctc.els.modules.biz.mapper.projects.ElsProjectFilesCategoryMapper;
import org.jctc.els.modules.biz.mapper.projects.ElsProjectFilesMapper;
import org.jctc.els.modules.biz.service.projects.ElsProjectFilesService;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Service
public class ElsProjectFilesServiceImpl extends BaseServiceImpl<ElsProjectFilesMapper, ElsProjectFiles> implements ElsProjectFilesService {

    @Autowired
    private ElsProjectFilesCategoryMapper elsProjectFilesCategoryMapper;

    @Override
    public List<ElsProjectFiles> listByProjectFiles(Long projectId) {
        List<ElsProjectFiles> elsProjectFiles = baseMapper.listByProjectFiles(projectId);
        return elsProjectFiles;
    }

    @Override
    public List<ElsProjectFilesCategory> selectCateList(Integer projectCategory) {
        List<ElsProjectFilesCategory> elsProjectFilesCategories = elsProjectFilesCategoryMapper.selectList(new QueryWrapper<ElsProjectFilesCategory>().eq("is_delete",0).eq("project_category", projectCategory));
        return elsProjectFilesCategories;
    }

    @Override
    public List<ElsProjectFiles> selectList(@RequestParam("projectId") Long projectId,
                                            @RequestParam("categoryId") Long categoryId) {
        return baseMapper.selectFileList(projectId,categoryId);
    }

    @Override
    public Integer delete(Long id) {
        return baseMapper.delete(new QueryWrapper<ElsProjectFiles>().eq("id", id.toString()));
    }
}
